import vm from "../main";

export const UIplugins = {
  //封装UI框架的提示信息插件
  message: function(params) {
    let type = '';
    switch (params.type) {
      case 'success': type = 'success'; break;
      case 'error': type = 'fail'; break;
      case 'loading': type = 'loading'; break;
      case 'html': type = 'html'; break;
      default: type = 'text'; break;
    };
    vm.$toast({
      message: params.message,
      type: type,
      duration: params.time ? params.time : 2000,
      forbidClick: params.forbidClick ? params.forbidClick : false,
      onClose: params.closeCallback &&
                typeof(params.closeCallback) == 'function' ?
                params.closeCallback : 
                null
    });
  }
}